import { API_URL } from "../constants";
import type { IDeviceAlarmLog, IResponse } from "../types";
import request from "./request";

export function getAlarmInfo(token: string, signal: AbortSignal) {
  return request<
    IResponse<{
      data: { alarms: IDeviceAlarmLog[]; warnings: IDeviceAlarmLog[] };
    }>
  >(`${API_URL}/business/deviceStatus/alarm/info`, {
    headers: { Authorization: token },
    signal,
  });
}

export function deleteAlarm(
  data: { deviceId: number; alarmName: string },
  token: string,
) {
  return request<IResponse>(
    `${API_URL}/business/deviceStatus/clear/alarm/${data.deviceId}/${data.alarmName}`,
    { method: "delete", headers: { Authorization: token } },
  );
}
